package com.itheima.controller;

import com.itheima.pojo.ClazzCountOption;
import com.itheima.pojo.JobOption;
import com.itheima.pojo.PageBean;
import com.itheima.pojo.Result;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

// 进行各种统计的控制器
@Slf4j
@RestController
public class ReportController {
    // 控制器依赖业务层
    @Autowired
    private ReportService reportService;

    /**
     * 统计员工职位
     *
     * @return
     */
    @GetMapping("/report/empJobData")
    public Result empJobData() {
        log.info("统计员工职位");
        // 调用业务层统计员工职位
        JobOption jobOption = reportService.empJobData();

        return Result.success(jobOption);
    }

    /**
     * 统计员工性别
     *
     * @return
     */
    @GetMapping("/report/empGenderData")
    public Result empGenderData() {
        log.info("统计员工性别");
        // 调用业务层统计员工性别
        List<Map> list = reportService.empGenderData();

        return Result.success(list);
    }


    /**
     * 统计学员的学历信息
     */
    @GetMapping("/report/studentDegreeData")
    public Result getStudentDegreeData() {
        log.info("统计学员的学历信息");
        List<Map> dataList = reportService.getStudentDegreeData();
        return Result.success(dataList);
    }

    /**
     * 班级人数统计
     */
    @GetMapping("/report/studentCountData")
    public Result getStudentCountData() {
        log.info("班级人数统计");
        ClazzCountOption clazzCountOption = reportService.getStudentCountData();
        return Result.success(clazzCountOption);
    }

    @GetMapping("/log/page")
    public Result getLogs(Integer page, Integer pageSize) {
        PageBean pageBean = reportService.getLogs(page, pageSize);

        return Result.success(pageBean);
    }
}
